package com.example.layui.config;

import com.cloopen.rest.sdk.CCPRestSmsSDK;
import org.springframework.stereotype.Component;

import java.util.Collection;
import java.util.HashMap;

@Component
public class SmsConfig {

    public void send(String to, String templateId, String[] datas)throws Exception {
        CCPRestSmsSDK sdk=new CCPRestSmsSDK();
        sdk.init("app.cloopen.com","8883");
        sdk.setAccount("8a216da8734b502301734c03374100a5","aec91813aefd43aaba6e860dcce73016");
        sdk.setAppId("8a216da8734b502301734c03382000ac");

        HashMap result=sdk.sendTemplateSMS(to,templateId,datas);

        if("000000".equals(result.get("statusCode"))){
            System.out.println("短信发送成功");
        }else{
            throw new Exception(result.get("statusCode").toString()+":"+result.get("statusMsg").toString());
        }
    }

    public static void main(String[] args) throws Exception {
        SmsConfig smsUtil = new SmsConfig();
        smsUtil.send("18598926592","1",new String[]{"傻逼","1"});
    }
}
